﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading;
using System.Windows;
using APRESS.TimeTracker.Services;
using Microsoft.Practices.Unity;

namespace APRESS.TimeTracker
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {

        private IUnityContainer _container;
        private INavigationService _navigation;

        public App()
        {
            ConfigureContainer();
        }

        private void ConfigureContainer()
        {
            _container = new UnityContainer();
            _container.RegisterType<IDialogService, DialogService>();
            _container.RegisterType<INavigationService, NavigationService>();
            _container.RegisterType<MainWindow>();
            _navigation = _container.Resolve<INavigationService>();

        }

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            Thread.Sleep(0);
            _navigation.ShowMainWindow();
        }

        protected override void OnSessionEnding(SessionEndingCancelEventArgs e)
        {
            base.OnSessionEnding(e);
            e.Cancel = _navigation.ConfirmClose();

        }
    }

}
